<?php
class WorkareaController extends Yaf_Controller_Abstract{
	const NET_OK = 10;
	const NET_NOAUTH = 20;
	public function init(){
		$user = cookie::get('user');
		if(!$user){
			$this->redirect('/Index/login/');
			return false;
		}
		Yaf_Loader::import('import.php');
	}
	/**
	 * 工作区首页
	 * @method indexAction
	 * @return [type]      [description]
	 * @author NewFuture
	 */
	public function indexAction(){
		$param['work_area'] = $this->getRequest()->getPost('work_area');
		//$result = int::inst('autoBG')->workSpaceSearch($params);
	}
	/**
	 * 工作区添加
	 * @method addWorkAreaAction
	 * @return [type]      [description]
	 * @author NewFuture
	 */
	public function addWorkAreaAction(){
		
	}
	/**
	 * 工作区编辑
	 * @method workAreaEditAction
	 * @return [type]      [description]
	 * @author NewFuture
	 */
	public function workAreaEditAction(){
		
		$params['workId'] = $this->getRequest()->getQuery('workId');
		//$result = net::inst('autoBG')->workAreaEdit($params);
		if(isset($result->ret)&&$result->ret == self::NET_OK){
			$this->getView()->assign('workDetail',$result->list[0]);
		}else if(isset($result->ret)&&$result->ret == self::NET_NOAUTH){
			$this->getView()->assign('error',$result->msg);
		}else{
			$this->getView()->assign('error','服务器连接失败！');
		}
		$this->getView()->assign('workId',$params['workId']);
	}
	/**
	 * 工作区详情
	 * @method workAreaDetailAction
	 * @return [type]      [description]
	 * @author NewFuture
	 */
	public function workAreaDetailAction(){
		$params['workId'] = $this->getRequest()->getRequest('workId');
		//$result = net::inst('autoBG')->workSpaceDetail($params);
		if(isset($result->ret)&&$result->ret == self::NET_OK){
			$this->getView()->assign('workDetail',$result->list[0]);
		}else if(isset($result->ret)&&$result->ret == self::NET_NOAUTH){
			$this->getView()->assign('error',$result->msg);
		}else{
			$this->getView()->assign('error','服务器连接失败！');
		}
	}
	/**
	 * 工作区路点添加
	 * @method addRoadAction
	 * @return [type]      [description]
	 * @author NewFuture
	 */
	public function addRoadAction(){
		$params = $this->getRequest()->getQuery('param');
		//$result = net::inst('autoBG')->workPathInit($params);
		if(isset($result->ret)&&$result->ret == self::NET_OK){
			$this->getView()->assign('pointDetail',$result->list[0]);
		}else if(isset($result->ret)&&$result->ret == self::NET_NOAUTH){
			$this->getView()->assign('error',$result->msg);
		}else{
			$this->getView()->assign('error','服务器连接失败！');
		}
	}
}